

<include file="public@header" />
</head>
<body>
<div class="wrap js-check-wrap">
    <ul class="nav nav-tabs">
        <li class="active"><a href="">全部用户</a></li>

    </ul>

    <form class="well form-inline margin-top-20" method="get" >

        用户名:
        <input type="text" class="form-control" id="username" style="width: 120px;"  placeholder="请输入用户名，id,电话">

        团队:
        <select class="form-control" name="hezuo" id="hezuo" style="width: 140px;">
            <option value=''>全部</option>
            <option value='0'>未绑定</option>
            <volist name="hezuo" id="hzs">
                <option value='{$hzs.id}'>{$hzs.title}</option>
            </volist>
        </select> &nbsp;&nbsp;

        类型:
        <select class="form-control" name="level" id="level" style="width: 140px;">
            <option value=''>全部</option>
            <option value='0'  >普通</option>
            <option value='2'  >负责人</option>
            <option value='1'  >加盟商</option>
        </select> &nbsp;&nbsp;

        <input type="button" id="selectval" class="btn btn-primary" value="搜索" />
        <a class="btn btn-danger" href="">清空</a>
    </form>

    <table class="table table-hover table-bordered">

        <table class="layui-hide" id="test" lay-filter="test"></table>

        <script type="text/html" id="barDemo">
            <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-xs" lay-event="seeorder">推广信息</a>
        </script>

        <!--    自定义    -->
        <script type="text/html" id="titleTpl">

            {{#  if(d.level == 2){ }} 负责人{{#  } }}
            {{#  if(d.level == 1){ }} 加盟商{{#  } }}
            {{#  if(d.level == 0){ }} 普通{{#  } }}

        </script>

        <script type="text/html" id="titleTpl1">
            {{#  if(d.kf == 0){ }} 无权限{{#  } }}
            {{#  if(d.kf == 1){ }} 入库管理{{#  } }}
        </script>

        <script>

            layui.use('table', function(){
                var table = layui.table;
                var curl="{:url('getalllist')}";

                var tableIns =table.render({
                    elem: '#test' ,
                    url:curl,
                    method: 'post',
                    toolbar: '#toolbarDemo',
                    title: '用户数据表',
                    cols: [[
                        {field:'id', title:'ID', width:80, fixed: 'left'}
                        ,{field:'name', title:'用户名',edit: 'text'}
                        ,{field:'mobile', title:'电话'}
                        ,{field:'team_title', title:'团队'}
                        ,{field:'agentid_name', title:'推荐人'}
                        ,{field:'level', title:'类型', templet: '#titleTpl'}
                        ,{field:'kf', title:'入库', templet: '#titleTpl1'}
                        ,{fixed: 'right', title:'操作', toolbar: '#barDemo'}
                    ]]
                    ,page: true
                });


                $("#selectval").click(function (){

                    var username=$("#username").val();
                    var level=$("#level").val();
                    var hezuo=$("#hezuo").val();

                    tableIns.reload({
                        where: { key:username ,level:level, hz:hezuo} ,
                        page: { curr: 1  }
                    });

                })

                // user/adminIndex/seelogs

                //表格工具行事件
                table.on('tool(test)', function(obj){
                    var data = obj.data;

                     if(obj.event === 'edit'){

                         var curl="{:url('user/adminIndex/seting')}?id="+data.id;

                         layer.open({
                             type: 2,
                             area: ['700px', '500px'],
                             content: curl,
                             success:function (){
                                 var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                 parent.layer.close(index); //再执行关闭
                             }
                         });
                    }

                    if(obj.event === 'seeorder'){

                        var curl="{:url('user/adminIndex/seelogs')}?id="+data.id;

                        layer.open({
                            type: 2,
                            area: ['900px', '600px'],
                            content: curl,
                            success:function (){
                                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                parent.layer.close(index); //再执行关闭
                            }
                        });
                    }


                });


            });
        </script>


    </table>

</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>